﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SD007
{
    public partial class TestUserControl : UserControl
    {
        public TestUserControl()
        {
            InitializeComponent();
            CheckForIllegalCrossThreadCalls = false;
        }

        public void AddError(ErrorType error)
        {
            this.bindingSource1.Add(error);
            this.dataGridView1.Refresh();
        }

        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == (this.dataGridView1.Columns.Count - 1))
            {
                if (this.dataGridView1.Rows.Count > e.RowIndex)
                {
                    DataGridViewRow row = this.dataGridView1.Rows[e.RowIndex];
                    MetricsForm metricForm = new MetricsForm((ErrorType)bindingSource1[e.RowIndex]);
                    metricForm.ShowDialog();
                }
            }
        }

        public void ClearError()
        {
            this.bindingSource1.Clear();
            this.dataGridView1.Refresh();
        }

        private void dataGridView1_DataError(object sender, DataGridViewDataErrorEventArgs e)
        {
            //do nothing
        }
    }
}
